<?php
/* @var $this CountAdminController */
/* @var $model CountAdmin */

$this->breadcrumbs = array(
    'Count Admins' => array('index'),
    'Create',
);
Yii::app()->clientScript->registerCoreScript('jquery');

$this->menu = array(
    array('label'=>'统计', 'url'=>array('company')),
    array('label'=>'最近20天', 'url'=>array('companyCountDay')),
    array('label'=>'最近12个月', 'url'=>array('companyCountYear')),
);
?>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/highcharts.js"></script>

<div class="countnum">总用户数:<?php echo $count_users;?> 总访问数:<?php echo $count_connections;?></div>
<!-- <div style="float: right;">
    <?php
    echo CHtml::dropDownList('gatewayname', $selected,CHtml::listData( Gateway::model()->findAll(' companyid='.Yii::app()->User->id), 'id', 'gatewayname'),
        array('empty'=>'-- All --','onchange'=>'onCilentChange(this)'));
    ?>
</div> -->
<div id="contents" style="width: 100%; height: 100%; margin: 0 auto"></div>
<script type="text/javascript">
    function onCilentChange(obj){
        var gwid = obj.value;
        location.href='<?php echo Yii::app()->createUrl('countAdmin/CompanyCountDay')?>&gatewayid='+gwid;
    }
    $(function () {
        var colorx = Highcharts.getOptions().colors;
        $('#contents').highcharts({
            chart: {
                type: 'spline'
            },
            title: {
                text: '统计最近20天'
            },
            xAxis: {
                categories: [<?php foreach ($x as $v) { echo "'".$v."',";} ?>],
                labels: {
                    rotation: -45
                }
            },
            yAxis: {
                title: {
                    text: '20天/日',
                    align: 'high'
                },
                min: 0,
                minorGridLineWidth: 0,
                gridLineWidth: 0,
                alternateGridColor: null,
                plotBands: [{
                    from: 0.3,
                    to: 1.5,
                    color: 'rgba(68, 170, 213, 0.1)',
                    label: {
                        style: {
                            color: '#606060'
                        }
                    }
                }, {
                    from: 1.5,
                    to: 3.3,
                    color: 'rgba(0, 0, 0, 0)',
                    label: {
                        style: {
                            color: '#606060'
                        }
                    }
                }, {
                    from: 3.3,
                    to: 5.5,
                    color: 'rgba(68, 170, 213, 0.1)',
                    label: {
                        style: {
                            color: '#606060'
                        }
                    }
                }, {
                    from: 5.5,
                    to: 8,
                    color: 'rgba(0, 0, 0, 0)',
                    label: {
                        style: {
                            color: '#606060'
                        }
                    }
                }, {
                    from: 8,
                    to: 11,
                    color: 'rgba(68, 170, 213, 0.1)',
                    label: {
                        style: {
                            color: '#606060'
                        }
                    }
                }, {
                    from: 11,
                    to: 14,
                    color: 'rgba(0, 0, 0, 0)',
                    label: {
                        style: {
                            color: '#606060'
                        }
                    }
                }, {
                    from: 14,
                    to: 15,
                    color: 'rgba(68, 170, 213, 0.1)',
                    label: {
                        style: {
                            color: '#606060'
                        }
                    }
                }]
            },
            tooltip: {
                valueSuffix: ''
            },
            plotOptions: {
                    spline: {
                        lineWidth: 4,
                        states: {
                            hover: {
                                lineWidth: 5
                            }
                        },
                        marker: {
                            enabled: false
                        }
                    }
            },
            series: [
                {
                    name: '当天用户数',
                    data: [<?php  foreach ($y as $k=>$v) {echo "{color: '#2f7ed8', y:".$v['user_to_day']."},"; } ?>], 
                    dataLabels: {
                        enabled: false,
                        color: '#2f7ed8',
                        align: 'center',
                        style: {
                            fontSize: '13px',
                            fontFamily: 'Verdana, sans-serif',
                            textShadow: '0 0 1px #2f7ed8'
                        }
                    }
                },
                {
                    name: '当天登陆数',
                    data: [<?php  foreach ($y as $k=>$v) { echo "{color: '#0d233a', y:".$v['connection_to_day']."},"; } ?>],
                    dataLabels: {
                        enabled: false,
                        color: '#0d233a',
                        align: 'center',
                        style: {
                            fontSize: '13px',
                            fontFamily: 'Verdana, sans-serif',
                            textShadow: '0 0 1px #0d233a'
                        }
                    }
                },
                {
                    name: '当天路人数',
                    data: [<?php  foreach ($y as $k=>$v) { echo "{color: '#8c8c8c', y:".$v['guests']."},";} ?>], 
                    dataLabels: {
                        color: '#8c8c8c',
                        align: 'center',
                        style: {
                            fontSize: '13px',
                            fontFamily: 'Verdana, sans-serif',
                            textShadow: '0 0 1px #8c8c8c'
                        }
                    }
                }
            ],
            credits: {
                enabled: false
            }
        });
    });
</script>

